import { NoSkinCellRenderer } from "../../../common/item/NoSkinCellRenderer";
import { Alert } from "../../../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { Language } from "../../../../../../extend/language/Language";
import { DropDirectionData } from "../info/DropDirectionData";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { CopyConfig } from "../../../../resource/CopyConfig";
import { ToolTipsManager } from "../../../../../../com/mui/manager/ToolTipsManager";
import { KingCopyToolTip } from "../../../common/tooltip/KingCopyToolTip";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { ObjCreate } from "../../../common/ObjCreate";
type int = number;
//class DropDirectionItemRenderer
    
    export  class DropDirectionItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            setSize(95, 140);
            return;
        }

        /* internal  */onClickenterCopyBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var onBtnClickHandler: Function;

            var loc1;
            onBtnClickHandler = null;
            e = arg1;
            onBtnClickHandler = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.EnterDirectionDropCopy, {"vo": data}));
                }
                return;
            }
            Alert.show(Language.getString(27908), null, Alert.OK | Alert.CANCEL, null, onBtnClickHandler);
            return;
        }

        /* internal  */onLoadResHandler(): void
        {
            var loc1=data as DropDirectionData;
            this._pic.bitmapData = GlobalClass.getBitmapData(this.PIC_NAME + loc1.index);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1 as DropDirectionData;
            var loc1=CopyConfig.instance.getKingCopyToolTipData(DropDirectionData(data).copyCode, DropDirectionData(data).index);
            ToolTipsManager.unregister(this._picSprite);
            ToolTipsManager.register(this._picSprite, KingCopyToolTip, loc1);
            LoaderHelp.addResCallBack(ResFileConst.kingCopy, this.onLoadResHandler);
            return;
        }

        protected /* override */ createChildren(): void
        {
            this._picSprite = new Object /* flash.display.Sprite */();
            this.addChild(this._picSprite);
            this._pic = new Object /* flash.display.Bitmap */();
            this._picSprite.addChild(this._pic);
            var loc1=ObjCreate.createGButton(Language.getString(27901), 6, 85, 70, 28, this, "ButtonRed");
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onClickenterCopyBtn);
            return;
        }

        /* internal */ /* const */PIC_NAME: string="KingCopyDropDirection_";

        /* internal */ /* var */_picSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_pic: Object /* flash.display.Bitmap */;
    }
